package com.yizn.learn.Condition;

/**
 * wait的测试类
 *
 * @author yisl
 * @create 2019-06-03 11:20
 */
public class WaitTest1 {

    public static void main(String[] args) {
        ThreadA ta = new ThreadA("ta");
        synchronized (ta){
            try {
                System.out.println(Thread.currentThread().getName()+" start ta");

                ta.start();

                System.out.println(Thread.currentThread().getName()+" block");
                ta.wait();

                System.out.println(Thread.currentThread().getName()+" continue");
            }catch (InterruptedException e){
                e.printStackTrace();
            }

        }
    }




    static class ThreadA extends Thread{

        public ThreadA(String name){
            super(name);
        }

        @Override
        public void run(){
            synchronized (this){
                System.out.println(Thread.currentThread().getName()+" wake up others");
                notify();
            }
        }
    }
}
